package guda.stark.dal.dao.impl;

import guda.grape.autogen.common.BaseDAO;
import guda.stark.dal.dao.BankChargeRuleDAO;
import guda.stark.dal.dataobject.BankChargeRuleDO;
import guda.grape.autogen.common.page.BaseQuery;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BankChargeRuleDAOImpl extends BaseDAO implements BankChargeRuleDAO {

    @Override
	public Long insert(BankChargeRuleDO bankChargeRule) {
	      try {
                return (Long) getSqlMapperW().insert("bank_charge_rule.insert",bankChargeRule);
          } catch (Exception e) {
                throw new RuntimeException(e);
          }

	}

    @Override
	public BankChargeRuleDO getBankChargeRuleById(Long ruleId) {
	    return (BankChargeRuleDO)getSqlMapClientTemplate().queryForObject("bank_charge_rule.getBankChargeRuleById", ruleId);
	}

    @Override
	public boolean delBankChargeRuleById(Long ruleId) {
	    int num = 0;
        try {
            num = getSqlMapperW().delete("bank_charge_rule.delBankChargeRuleById",ruleId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if(num>0){
            return true;
        }else{
            return false;
        }
	}

    @Override
	public List<BankChargeRuleDO> getBankChargeRuleByIds(List idsList) {
        Map m = new HashMap();
        m.put("idsList",idsList);
		return getSqlMapClientTemplate().queryForList("bank_charge_rule.selectByIds", m);
	}

    @Override
	public void cleanAutoIncrement(Long ruleId) {
	    try {
            getSqlMapperW().update("bank_charge_rule.cleanAutoIncrement",ruleId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
	}

    @Override
    public List<BankChargeRuleDO> selectForPage(BaseQuery baseQuery) {
        return getSqlMapClientTemplate().queryForList("bank_charge_rule.selectForPage", baseQuery);
    }

    @Override
    public int countForPage(BaseQuery baseQuery) {
        return (Integer)getSqlMapClientTemplate().queryForObject("bank_charge_rule.countForPage",baseQuery);
    }

    @Override
    public void updateByIdSelective(BankChargeRuleDO bankChargeRule) {
        try {
            getSqlMapperW().update("bank_charge_rule.updateByIdSelective",bankChargeRule);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}

